package com.ruoyi.performance.controller;

import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.performance.domain.PerfCheck;
import com.ruoyi.performance.domain.PerfCheckresult;
import com.ruoyi.performance.service.IPerfCheckService;
import com.ruoyi.performance.utils.MyUtils;


/**
 * 绩效考核管理 提供者
 * 
 * @author ygx
 * @date 2020-08-31
 */
@RestController
@RequestMapping("check")
public class PerfCheckController extends MyUtils
{
	
	@Autowired
	private IPerfCheckService perfCheckService;

	
	/**
	 * 查询${tableComment}
	 */
	@GetMapping("get/{perfcheckId}")
	public R get(@PathVariable("perfcheckId") Long perfcheckId)
	{   
		startPage();
		return jacResult(perfCheckService.selectPerfCheckById(perfcheckId));
		
	}
	
	/**
	 * 查询绩效考核管理列表
	 */
	@GetMapping("list")
	public R list(PerfCheck perfCheck)
	{
		startPage();
        return result(perfCheckService.selectPerfCheckList(perfCheck));
	}
	
	/**
	 * 绩效考核打分列表
	 */
	@GetMapping("resultList")
	@JsonView(value = PerfCheckresult.selectResultList.class)
	public Map<String,Object> resultList(PerfCheck perfCheck)
	{   
		startPage();
        return result(perfCheckService.selectResultList(perfCheck));
	}
	
	
	/**
	 * 查询绩效考核管理列表(all)
	 */
	@GetMapping("resultListAll")
	@JsonView(value = PerfCheckresult.selectResultList.class)
	public Map<String,Object> resultListAll(PerfCheck perfCheck)
	{   
		startPage();
        return result(perfCheckService.selectResultListAll(perfCheck));
	}
	
	
	
	/**
	 * 新增保存绩效考核管理
	 */
	@PostMapping("save")
	public Map<String,String> addSave(@RequestBody Map<String,List<PerfCheck>> datas)
	{		
		return jacResultMsg(perfCheckService.insertPerfCheck(datas));
	}

	/**
	 * 修改保存绩效考核管理
	 */
	@PostMapping("update")
	public R editSave(@RequestBody PerfCheck perfCheck)
	{		
		return toAjax(perfCheckService.updatePerfCheck(perfCheck));
	}
	
	/**
	 * 修改绩效考核单状态
	 */
	@PostMapping("updateStatus")
	public Map<String,String> editSave(@RequestBody Map<String, List<PerfCheck>> datas)
	{		
		return jacResultMsg(perfCheckService.updatePerfStatus(datas));
	}
	
	/**
	 * 删除${tableComment}
	 */
	@PostMapping("remove")
	public Map<String,String> remove(String ids)
	{		
		return jacResultMsg(perfCheckService.deletePerfCheckByIds(ids));
	}
	
	/**
	 * 生成审批单号（如：VPCBJ202008030001）
	 */
	@GetMapping("getVpcCode/{companycode}")
	public R getContractCode(@PathVariable("companycode") String companycode)
	{
		
		return jacResultString("constractCode",perfCheckService.createContractCode(companycode,"VPC"));
	}
	
}
